<template>
  <div class="top">
    <div class="left">
      <span class="lbtn" @click="handleBack">首页</span>
    </div>
    <div class="center">
      <div class="title">智慧旅游可视化大平台</div>
    </div>
    <div class="right">
      <span class="rbtn">统计报告</span>
      <span class="time">当前时间:{{ time }}</span>
    </div>
  </div>
</template>

<script setup lang="ts">
//引入路由
import { useRouter } from 'vue-router'
//引入时间插件
//@ts-ignore
import moment from 'moment'
import { ref, onMounted, onBeforeUnmount } from 'vue'
//路由
let $router = useRouter()
//时间
let time = ref(moment().format('YYYY-MM-DD:hh-mm-ss'))
let timer = ref<number>(1)

onMounted(() => {
  timer.value = setInterval(() => {
    time.value = moment().format('YYYY-MM-DD:hh-mm-ss')
  }, 1000)
  console.log(time.value)
})
onBeforeUnmount(() => {
  clearInterval(timer.value)
})

const handleBack = () => {
  $router.push('/home')
}
</script>

<style scoped lang="scss">
.top {
  width: 100%;
  height: 40px;
  display: flex;
  margin: 5px 0px;
  .left {
    flex: 1;
    background: url(../../images/dataScreen-header-left-bg.png) no-repeat;
    background-size: 100% 100%;
    display: float;
    .lbtn {
      width: 150px;
      height: 40px;
      float: right;
      //背景
      background: url(../../images/dataScreen-header-btn-bg-l.png);
      background-size: 100% 100%;
      //字体
      text-align: center;
      line-height: 40px;
      font-size: 20px;
      color: #29fcff;
      //鼠标选中改变样式
      cursor: pointer;
    }
    .lbtn:hover {
      transition: 0.2s;
      color: white;
    }
  }
  .center {
    flex: 2;
    .title {
      width: 100%;
      height: 74px;
      background: url(../../images/dataScreen-header-center-bg.png) no-repeat;
      background-size: 100% 100%;
      text-align: center;
      line-height: 74px;
      font-size: 35px;
      color: #29fcff;
    }
  }
  .right {
    flex: 1;
    background: url(../../images/dataScreen-header-right-bg.png) no-repeat;
    background-size: 100% 100%;
    display: float;
    .rbtn {
      width: 150px;
      height: 40px;
      float: left;
      //背景
      background: url(../../images/dataScreen-header-btn-bg-r.png);
      background-size: 100% 100%;
      //字体
      text-align: center;
      line-height: 40px;
      font-size: 20px;
      color: #29fcff;
      //鼠标选中改变样式
      cursor: pointer;
    }
    .rbtn:hover {
      transition: 0.2s;
      color: white;
    }
    .time {
      float: right;
      margin-right: 20px;
      //字体
      text-align: center;
      line-height: 40px;
      font-size: 20px;
      color: #29fcff;
    }
  }
}
</style>
